#ifndef QRCODEACTIVATIONWIDGET_H
#define QRCODEACTIVATIONWIDGET_H

#include <QWidget>
#include <QTimer>
#include <QNetworkRequest>
#include <QNetworkAccessManager>
#include <QMessageBox>
#include "receive_dbus.h"
#include "interface.h"
extern "C" {
#include <kylin-activation.h>
}

namespace Ui {
class QrCodeActivationWidget;
}

class QrCodeActivationWidget : public QWidget
{
    Q_OBJECT

public:
    explicit QrCodeActivationWidget(QWidget *parent = nullptr);
    ~QrCodeActivationWidget();
    void checkIfOnline();
    void resetControlsState(int type);
    void netRequestInit();//http通信初始化

private:
    Ui::QrCodeActivationWidget *ui;
    bool m_checkIfOnLine=false;

    gint canset_serial_flag = 0;
    QString newserial = "";
    gint serial_edit_flag = 1;
    gint customer_edit_flag = 1;

    QTimer *m_timer=nullptr;//图形动画计时器
    QTimer *act_timer = nullptr;//自动激活计时器
    int count_time=0;//自动激活计时

    QLabel *activationiconlabel = nullptr;
    QLabel *activationremindlabel = nullptr;

    //自动激活
    QNetworkRequest act_request;
    QNetworkAccessManager* act_naManager = nullptr;

    //网络检查
    bool _isCheckNet=false;//网络检测标志位

protected:
    void initData();//加载二维码
    void activeSys(QString serial, QString code);
    void paintEvent(QPaintEvent *event);
    void signalSlotConInit();


private slots:
    void on_returnbtn_clicked();
    void on_activebtn_clicked();

signals:
    void returnSignal();
    void sigLookUpHostResult(bool result);
    void activateSucceed();
    void activationMessageSignal(int activation);//激活信息发送信号
};

#endif // QRCODEACTIVATIONWIDGET_H
